<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('finance_branch_detail_bills', function (Blueprint $table) {
            $table->id();

            $table->unsignedInteger('branch_bill_id')->comment('分部账单id');
            $table->unsignedInteger('sub_bill_id')->nullable()->comment('对应的子账号账单id');
            $table->unsignedInteger('shop_id')->comment('店铺id');
            $table->string('shop_name')->nullable()->comment('店铺名称');
            $table->unsignedInteger('sub_account_id')->comment('子账号id');
            $table->string('sub_account')->nullable()->comment('子账号名称');
            $table->string('service_period')->nullable()->comment('子账号服务日期');
            $table->unsignedInteger('service_days')->nullable()->comment('服务天数');
            $table->string('consult_column')->nullable()->comment('平台咨询 字段');
            $table->unsignedInteger('consult_quantity')->default(0)->comment('客服回复量');
            $table->string('service_price')->nullable()->comment('计算方式(个/元)');
            $table->decimal('pay_amount',12,1)->nullable()->comment('应结算金额');
            $table->decimal('shop_other_fee',12,1)->nullable()->comment('店铺管理费');
            $table->decimal('overtime_fee',12,1)->nullable()->comment('加班费');
            $table->string('remark')->nullable()->comment('备注');

            $table->decimal('penalty_amount',10,1)->nullable()->comment('罚款');
            $table->integer('department_quote_id')->nullable()->comment('分部报价id');
            $table->integer('quotation_group_id')->nullable()->comment('报价分组id');
            $table->integer('quote_total_consult')->nullable()->comment('报价总咨询量');
            $table->integer('total_quote_consult_days')->nullable()->comment('报价总天数');
            $table->integer('quote_day_average_consult')->nullable()->comment('报价日平均咨询量');
            $table->decimal('service_quote_final',10,1)->nullable()->comment('最终报价');

            $table->timestamps();
        });
        \DB::statement("ALTER TABLE `finance_branch_detail_bills` comment '分部账单子账号账单信息'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('finance_branch_detail_bills');
    }
};
